<?php

namespace app\api\model\shanghui;

use app\api\model\Setting as SettingModel;
use app\common\service\Order as OrderService;
use app\common\enum\recharge\order\PayStatus as PayStatusEnum;
use app\common\exception\BaseException;
use app\common\model\BaseModel;
use think\Db;
/**
 * 商会升级订单模型
 * Class Order
 * @package app\api\model\recharge
 */
class Order extends BaseModel
{
    /**
     * 隐藏字段
     * @var array
     */
    protected $hidden = [
        'wxapp_id',
    ];
    protected $name = 'shanghui_order';
    /**
     * 获取订单列表
     * @param $userId
     * @return \think\Paginator
     * @throws \think\exception\DbException
     */
    public function getList($shanghui_id)
    {
        // 获取列表数据
        return $this->where('shanghui_id', '=', $shanghui_id)
            ->where('pay_status', '=', PayStatusEnum::SUCCESS)
            ->order(['create_time' => 'desc'])
            ->paginate(15, false, [
                'query' => request()->request()
            ]);
    }

    /**
     * 获取订单详情(待付款状态)
     * @param $orderNo
     * @return self|null
     * @throws \think\exception\DbException
     */
    public static function getPayDetail($orderNo,$pay_status = '')
    {
        if($pay_status == ''){
           $pay_status = PayStatusEnum::PENDING;
        }
        return self::detail(['order_no' => $orderNo, 'pay_status' => $pay_status]);
    }
    /**
     * 获取订单详情(多条件)
     */
    public static function detail($where){
        return self::where($where)->find();
    }
    


}